<!DOCTYPE html>
<html lang="en">
<style>
    ul.group-list li {
        white-space: nowrap;float: left;
        width: 150px; height: 25px;
        padding: 3px 5px;list-style-type: none;
        list-style-position: outside;border: 0px;margin: 0px;
    }
    input[type=checkbox], input[type=radio] {
        display: inline-block;
    }
</style>

{include file="Public/head"}

<body data-type="widgets">
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    {include file='Public:header'}
    {include file='Public:menu2'}



    <!-- 内容区域 -->
    <div class="tpl-content-wrapper" >
        <div class="row-content am-cf">
            <div class="row">

                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl">编辑退货申请</div>
                            <div class="widget-function am-fr">
                                <a href="javascript:;" class="am-icon-cog"></a>
                            </div>
                        </div>
                        <div class="widget-body am-fr">
                            <form id="roleform" form="submit" method="post">
                                <input type="hidden" name="id" value="{$delivery.id}">
                                <!--通用信息-->
                                <div class="tab-content col-md-10">
                                    <div class="tab-pane active" id="tab_tongyong">
                                        <table class="table table-bordered">
                                            <tbody>
                                            <tr>
                                                <td class="col-sm-2">订单编号：</td>
                                                <td class="col-sm-8">
                                                    <input type="hidden" name="order_id" id="order_id" value="{$delivery.order_id}">
                                                    <input type="hidden" name="user_id" id="user_id" value="{$delivery.user_id}">
                                                    <input type="hidden" name="rec_id" id="rec_id" value="{$delivery.rec_id}">
                                                    <a href="#" id="order_sn" data-val="{$delivery.order_sn}">{$delivery.order_sn}</a>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>用户：</td>
                                                <td>{$delivery.nickname}</td>
                                            </tr>
                                            <tr>
                                                <td>申请日期：</td>
                                                <td>{$delivery.addtime|date='Y-m-d H:i:s',###} </td>
                                            </tr>
                                            <tr>
                                                <td>商品名称：</td>
                                                <td>
                                                    <input type="hidden" id="goods_id" name="goods_id" value="{$delivery.goods_id}">
                                                    <a href="/index.php/Home/Goods/goodsInfo/id/104" target="_blank">{$delivery.goods_name}</a>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>商品规格：</td>
                                                <td>
                                                    {$delivery.spec_key_name}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>数量：</td>
                                                <td>
                                                    {$delivery.goods_num}
                                                    <input type="hidden" name="goods_num" value="{$delivery.goods_num}">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>退换货：</td>
                                                <td>
                                                    <div class="form-group col-xs-3">
                                                        <select name="type" class="form-control">
                                                            <option value="0" {if $delivery.type=="0"} selected="selected"{/if}>退货</option>
                                                            <option value="1" {if $delivery.type=="1"} selected="selected"{/if}>换货</option>
                                                        </select>
                                                    </div>

                                                    <input class="btn btn-primary" onclick="drawing()" value="退款到用户余额">



                                                </td>
                                            </tr>
                                            <tr>
                                                <td>退货描述：</td>
                                                <td>
                                                    <textarea id="reason" cols="" rows="" readonly="readonly" class="area" style="width:400px; height:120px;">{$delivery.reason}</textarea>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>用户上传照片：</td>
                                                <td>
                                                    {notempty name="$return_goods"}
                                                {foreach name="return_goods" key="k" item="v"}
                                                    <a href="{$v}" target="_blank"><img src="{$v}" width="85" height="85"></a>
                                                {/foreach}
                                                    {/notempty}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>状态：</td>
                                                <td>
                                                    <div class="form-group  col-xs-3">
                                                        <select class="form-control" name="status">
                                                            <option value="0" {if $delivery.status=="0"}selected="selected"{/if}>未处理</option>
                                                            <option value="1" {if $delivery.status=="1"}selected="selected"{/if}>处理中</option>
                                                            <option value="2" {if $delivery.status=="2"}selected="selected"{/if}>已完成</option>
                                                        </select>
                                                    </div>

                                                </td>
                                            </tr>
                                            <tr>
                                                <td>处理备注：</td>
                                                <td>
                                                    <textarea name="remark" id="remark" cols="" rows="" class="area" style="width:400px; height:120px;">{$delivery.remark}</textarea>
                                                </td>
                                            </tr>
                                            </tbody>
                                            <tfoot>
                                            <tr>
                                                <td><input type="hidden" name="id" value="{$delivery.id}">
                                                </td>{if $delivery.status!="2"}
                                                <td class="text-right"><input class="btn btn-primary" type="submit" value="保存"></td>
                                                {/if}
                                            </tr>
                                            </tfoot>
                                        </table>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</body>
{include file='Public:script'}
{include file='Public:validation'}

<script>

    //提交
    function roleSubmit(){
        var form=document.getElementById("roleform");
        var formData=new FormData(form);
        $.ajax({
            url:"{:Url('addData')}",
            type:'POST',
            data:formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success:function(res){
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 2000,icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 1}, function(){
                    window.location.href=document.referrer;

                });
            }
        });
    }


    //退款
    function drawing(){
        var param = new Object();
        param['order_id']=$('#order_id').val();
        param['goods_id']=$('#goods_id').val();
        param['user_id']=$('#user_id').val();
        param['rec_id']=$('#rec_id').val();
        param['order_sn']=$('#order_sn').attr('data-val');
            $.post(
            "{:url('drawing')}",
            param,
            function(ret){
                if(ret.code != 200){
                    layer.msg(ret.msg, {icon: 2});
                    return false;
                }
                layer.msg(ret.msg, {icon: 1,time:2000},function() {
                    return false;
                });
            });
    }
</script>

</html>